package com.sinosoft.brokerchannel.server.impl;





import com.sinosoft.brokerchannel.base.utile.*;
import com.sinosoft.brokerchannel.base.utile.token.Token;
import com.sinosoft.brokerchannel.base.utile.token.TokenOperate;
import com.sinosoft.brokerchannel.entity.vo.*;
import com.sinosoft.brokerchannel.server.IusService;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Service;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.*;

@Service
public class IusServiceImpl implements IusService {
    /**
     * 渠道协议查询
     */
    public IusChannelQueryResponse selectChannel(IusChannelQueryRequest request) throws Exception {
        IusChannelQueryResponse response = new IusChannelQueryResponse();
        IusChannelQueryResponseMain responseBody;
        IusChannelQueryRequestMain requestBody = request.getRequestBody();
        if (requestBody.getPage() == null || requestBody.getPage() == 0 || "".equals(requestBody.getPage())) {
            throw new BusinessException("0055", "当前页数不能为空或0！");
        }
        if (requestBody.getPageSize() == null || requestBody.getPageSize() == 0
                || "".equals(requestBody.getPageSize())) {
            throw new BusinessException("0055", "分页大小不能为空或0！");
        }
        if (requestBody.getChannelAgreeName() == null || "".equals(requestBody.getChannelAgreeName())) {
            throw new BusinessException("0055", "渠道协议名称为空");
        }
        if (requestBody.getOrgId() == null || "".equals(requestBody.getOrgId())) {
            throw new BusinessException("0055", "机构代码参数异常");
        }
        String param = requestBody.getChannelAgreeName();
        String param1 = requestBody.getOrgId();
        boolean b = true;
        String str2 = null;
        try {
            try {
                param = URLEncoder.encode(param, "UTF-8");
            } catch (Exception e) {
                throw new BusinessException("0055", "字符转换异常！");
            }
            String url = "http://127.0.0.1:10002/client/list/?pageName=IUSChannel&formName=select&userKeys=portal-v1.0&orgId=" + param1 + "&channelAgreeName=" + param;
            str2 = HttpclientUtil.doGet(url, null, "UTF-8", b);
            responseBody = StringToresponseBody(str2);
            response.setResponseBody(responseBody);
        } catch (Exception e) {
            throw new BusinessException("0056", "数据查询异常！");
        }
        return response;
    }

    /**
     * 保险协议查询
     */
    @Override
    public List<SaleBXInformationVo> selectInsuredAgree(String request) throws Exception {
        List<SaleBXInformationVo> ja = new ArrayList<SaleBXInformationVo>();
        if (request == null || "".equals(request)) {
            throw new BusinessException("0055", "缺少渠道参数！");
        }
        boolean b = true;
        String str = null;
        try {
            String url = "http://127.0.0.1:10002/client/list/?pageName=ggInsuredAgree-ggChannelAgree&formName=select&userKeys=portal-v1.0&ggChannelAgreeDetail.w_channelAgreeCode=" + request;
            str = HttpclientUtil.doGet(url, null, "UTF-8", b);
            ja = String1ToInt(str);
        } catch (Exception e) {
            throw new BusinessException("0056", "数据查询异常！");
        }
        return ja;
    }

    /**
     * 机构信息查询
     */
    @Override
    public IusOrgQueryResponse selectOrg(IusOrgQueryRequest request) throws Exception {
        IusOrgQueryResponse response = new IusOrgQueryResponse();
        IusOrgQueryResponseMain responseBody;
        IusOrgQueryRequestMain requestBody = request.getRequestBody();
        if (requestBody.getPage() == null || requestBody.getPage() == 0 || "".equals(requestBody.getPage())) {
            throw new BusinessException("0055", "当前页数不能为空或0！");
        }

        if (requestBody.getPageSize() == null || requestBody.getPageSize() == 0
                || "".equals(requestBody.getPageSize())) {
            throw new BusinessException("0055", "分页大小不能为空或0！");
        }
        if (requestBody.getUserEName() == null || "".equals(requestBody.getUserEName())) {
            throw new BusinessException("0055", "登陆账号获取异常");
        }
        if (requestBody.getOrgCName() == null || "".equals(requestBody.getOrgCName())) {
            throw new BusinessException("0055", "机构名称不能为空");
        }
        String param = requestBody.getUserEName();
        boolean b = true;
        String str = null;
        String str1 = null;
        String str2 = null;
        try {
            String url = "http://127.0.0.1:10002/client/list/?pageName=node-manager&formName=userSearchForm&userKeys=portal-v1.0&uctUser.w_userEname=" + param;
            str = HttpclientUtil.doGet(url, null, "UTF-8", b);
            JSONObject jsonObject = JSONObject.fromObject(str);
            try {
                JSONArray jsonArray = jsonObject.getJSONArray("rows");
                if (jsonArray.size() > 0) {
                    JSONObject jo = jsonArray.getJSONObject(0);
                    str1 = jo.getString("orgId");//查找机构where条件
                } else {
                    throw new BusinessException("0055", "数据查询异常");
                }
            } catch (Exception e) {
                throw new BusinessException("0056", "数据转换异常！");
            }
        } catch (Exception e) {
            throw new BusinessException("0056", "数据查询异常！");
        }
        try {
            String param1 = requestBody.getOrgCName();
            try {
                param1 = URLEncoder.encode(param1, "UTF-8");
            } catch (Exception e) {
                throw new BusinessException("0055", "字符转换异常！");
            }
            String url1 = "http://127.0.0.1:10002/client/list/?pageName=org-list&formName=searchForm-new&userKeys=portal-v1.0&uctOrg.wl_orgCname=" + param1 + "&uctOrg.wi_orgId=" + str1;
            str2 = HttpclientUtil.doGet(url1, null, "UTF-8", b);
            responseBody = StringToIusResponseBody(str2);
            response.setResponseBody(responseBody);
        } catch (Exception e) {
            throw new BusinessException("0056", "数据查询异常！");
        }

        response.setResponseBody(responseBody);
        return response;
    }

    /**
     * 短信校验
     */
    @Override
    public IusMessagingResponse messaging(IusMessagingRequest request) throws Exception {
        IusMessagingResponse response = new IusMessagingResponse();
        IusMessagingResponseMain responseBody;
        IusMessagingRequestMain requestBody = request.getRequestBody();
        if (requestBody.getPhoneNumber() == null || "".equals(requestBody.getPhoneNumber())) {
            throw new BusinessException("0055", "手机号不能为空！");
        }
        String str = null;
        responseBody = StringToIusMessagingResponseBody(str);
        response.setResponseBody(responseBody);
        return response;
    }

    /**
     * 提现接口
     */
    @Override
    public IusMoneyResponse withdrawDeposit(IusMoneyRequest request) throws Exception {
        IusMoneyResponse response = new IusMoneyResponse();
        IusMoneyResponseMain responseBody;
        IusMoneyRequestMain requestBody = request.getRequestBody();
        boolean b = true;
        String str = null;
        String str1 = null;
        if (requestBody.getAccountNumber() == null || "".equals(requestBody.getAccountNumber())) {
            throw new BusinessException("0055", "银行卡号不能为空！");
        }
        if (requestBody.getAccountCode() == null || "".equals(requestBody.getAccountCode())) {
            throw new BusinessException("0055", "银行密码不能为空！");
        }
        if (requestBody.getUserEname() == null || "".equals(requestBody.getUserEname())) {
            throw new BusinessException("0055", "用户登陆信息异常！");
        }
        if (requestBody.getMoney() == null || "".equals(requestBody.getMoney())) {
            throw new BusinessException("0055", "提现金额不能为空！");
        }
        if (requestBody.getAccountMan() == null || "".equals(requestBody.getAccountMan())) {
            throw new BusinessException("0055", "银行户主不能为空！");
        }
        if (requestBody.getAccountName() == null || "".equals(requestBody.getAccountName())) {
            throw new BusinessException("0055", "银行信息不能为空！");
        }
        String param = requestBody.getAccountCode();
        String param1 = requestBody.getMoney();
        String param2 = requestBody.getAccountName();
        String param3 = requestBody.getUserEname();
        String param4 = requestBody.getAccountNumber();
        String param5 = null;
        try {
            String url1 = "http://127.0.0.1:10002/client/list/?pageName=gp-balance&formName=searchForm&userKeys=portal-v1.0&gpBalance.w_salesmanCode=" + param3;
            String strN = HttpclientUtil.doGet(url1, null, "UTF-8", b);
            JSONObject jsonObject = JSONObject.fromObject(strN);
            JSONArray jsonArray = jsonObject.getJSONArray("rows");
            if (jsonArray.size() > 0) {
                JSONObject jo = jsonArray.getJSONObject(0);
                JSONObject channel = jo.getJSONObject("gpBalance");
                param5 = channel.getString("balanceAmount");
            }
        } catch (Exception e) {
            throw new BusinessException("0056", "余额查询异常！");
        }
        if (Double.parseDouble(param1) > Double.parseDouble(param5)) {
            throw new BusinessException("0055", "提现金额不能大于余额！");
        }
        double gold = Double.parseDouble(param5) - Double.parseDouble(param1);
        String goldMoney = String.format("%.2f", gold);
        //模拟已调取银联接口验证密码，如果匹配则转账提现成功
        String url = null;
        if ("123456".equals(param)) {
            try {
                Map<String, String> map = new HashMap<>();
                map.put("pageName", "gp-balance");
                map.put("formName", "editForm");
                map.put("userKeys", "portal-v1.0");
                map.put("doCode", "doService");
                map.put("gpBalance.balanceAmount", goldMoney);
                map.put("gpBalance.w_salesmanCode", param3);
                url = "http://127.0.0.1:10002/client/service/";
                str = HttpclientUtil.doPost(url, map, "utf-8", true);
                responseBody = StringToIusMoneyResponseBody(str);
                response.setResponseBody(responseBody);
            } catch (Exception e) {
                throw new BusinessException("0056", "银行转账成功，余额修改失败！");
            }
            Date date = new Date();
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
            try {
                //模拟提现时间
                String dateStr = df.format(date);
                //模拟银行返回的提现流水号
                int num = (int) (Math.random() * 9000) + 1000;
                String sNo = "O0000030001201700" + num;
                //模拟手续费
                double d = Double.parseDouble(param1) * 0.01;
                String dTest = String.format("%.2f", d);
                //模拟到账时间
                Calendar cal = Calendar.getInstance();
                cal.setTime(df.parse(df.format(date)));
                cal.add(Calendar.HOUR_OF_DAY, 1);
                Map<String, String> map1 = new HashMap<>();
                map1.put("pageName", "add-gpPresentTrack");
                map1.put("formName", "addForm");
                map1.put("userKeys", "portal-v1.0");
                map1.put("doCode", "doService");
                map1.put("gpPresentTrack.flowNumber", sNo);
                map1.put("gpPresentTrack.money", String.format("%.2f", Double.parseDouble(param1)));
                map1.put("gpPresentTrack.userEname", param3);
                map1.put("gpPresentTrack.time", dateStr);
                map1.put("gpPresentTrack.accountNumber", param4);
                map1.put("gpPresentTrack.balance", goldMoney);
                map1.put("gpPresentTrack.bank", param2);
                map1.put("gpPresentTrack.serviceCharge", dTest);
                map1.put("gpPresentTrack.paymentDate", df.format(cal.getTime()));
                //模拟提现成功
                map1.put("gpPresentTrack.moneyType", "1");//1为提现成功，0为提现中
                str1 = HttpclientUtil.doPost(url, map1, "UTF-8", b);
                JSONObject jsonObject = JSONObject.fromObject(str1);
                String jsonArray = jsonObject.getString("flag");
                if ("T".equals(jsonArray)) {

                } else {
                    throw new BusinessException("0056", "银行提现成功，提现轨迹保存失败！");
                }

            } catch (Exception e) {
                throw new BusinessException("0056", "银行转账成功，提现轨迹保存失败！");
            }
        } else {
            throw new BusinessException("0055", "银行卡密码不正确！");
        }
        return response;

    }

    /**
     * 物流查询
     */
    @Override
    public IusLogisticsQueryResponse selectLogistics(IusLogisticsQueryRequest request) throws Exception {
        IusLogisticsQueryResponse response = new IusLogisticsQueryResponse();
        IusLogisticsQueryResponseMain responseBody;
        IusLogisticsQueryRequestMain requestBody = request.getRequestBody();
        KdniaoUtil api = new KdniaoUtil();//调用快递查询类
        String str = null;
        if (requestBody.getLogisticsCode() == null || "".equals(requestBody.getLogisticsCode())) {
            throw new BusinessException("0055", "快递编号不能为空！");
        }
        if (requestBody.getLogisticsNumber() == null || "".equals(requestBody.getLogisticsNumber())) {
            throw new BusinessException("0055", "快递单号不能为空！");
        }
        String code = requestBody.getLogisticsCode();
        String number = requestBody.getLogisticsNumber();
        try {
            str = api.getOrderTracesByJson(code, number);
        } catch (Exception e) {
            e.printStackTrace();
        }
        responseBody = StringToIusLogisticsResponseBody(str);
        response.setResponseBody(responseBody);
        return response;
    }

    /**
     * 余额查询
     */
    @Override
    public IusSettletFeeResponse selectGpSettletFee(IusSettletFeeRequest request) throws Exception {
        IusSettletFeeResponse response = new IusSettletFeeResponse();
        IusSettletFeeResponseMain responseBody;
        IusSettletFeeRequestMain requestBody = request.getRequestBody();
        if (requestBody.getUserEName() == null || "".equals(requestBody.getUserEName())) {
            throw new BusinessException("0055", "登陆账号获取异常");
        }
        String param = requestBody.getUserEName();
        boolean b = true;
        String str = null;
        try {
            String url = "http://127.0.0.1:10002/client/list/?pageName=gp-balance&formName=searchForm&userKeys=portal-v1.0&gpBalance.w_salesmanCode=" + param;
            str = HttpclientUtil.doGet(url, null, "UTF-8", b);
            responseBody = StringToGpSettletFeeResponseBody(str);
            response.setResponseBody(responseBody);
        } catch (Exception e) {
            throw new BusinessException("0056", "数据查询异常！");
        }

        response.setResponseBody(responseBody);
        return response;
    }

    /**
     * 台账信息查询
     */
    @Override
    public IusAccountResponse selectGuAccount(IusAccountRequest request) throws BusinessException {
        IusAccountResponse response = new IusAccountResponse();
        IusAccountResponseMain responseBody;
        IusAccountRequestMain requestBody = request.getRequestBody();
        if (requestBody.getSettleNo() == null || "".equals(requestBody.getSettleNo())) {
            throw new BusinessException("0055", "结算单号获取异常");
        }
        if (requestBody.getPage() == null || requestBody.getPage() == 0 || "".equals(requestBody.getPage())) {
            throw new BusinessException("0055", "当前页数不能为空或0！");
        }

        if (requestBody.getPageSize() == null || requestBody.getPageSize() == 0
                || "".equals(requestBody.getPageSize())) {
            throw new BusinessException("0055", "分页大小不能为空或0！");
        }
        String param = requestBody.getSettleNo();
        String param1 = Integer.toString(requestBody.getPage());
        String param2 = Integer.toString(requestBody.getPageSize());
        boolean b = true;
        String str = null;
        try {
            String url = "http://127.0.0.1:10002/client/list/?pageName=gu-account&formName=seForm&userKeys=portal-v1.0&guTemporaryBusiness.w_settleNo=" + param + "&page=" + param1 + "&rows=" + param2;
            str = HttpclientUtil.doGet(url, null, "UTF-8", b);
            responseBody = StringToIusAccountResponseBody(str);
            response.setResponseBody(responseBody);
        } catch (Exception e) {
            throw new BusinessException("0056", "数据查询异常！");
        }

        response.setResponseBody(responseBody);
        return response;
    }

    /**
     * 用户登陆
     */
    @Override
    public IusLoginQueryResponse selectLogin(IusLoginQueryRequest request) throws BusinessException {
        IusLoginQueryResponse response = new IusLoginQueryResponse();
        IusLoginQueryResponseMain responseBody;
        IusLoginQueryRequestMain requestBody = request.getRequestBody();
        if (requestBody.getParityType() == null || "".equals(requestBody.getParityType())) {
            throw new BusinessException("0055", "账号失效");
        }
        if (requestBody.getUserName() == null || "".equals(requestBody.getUserName())) {
            throw new BusinessException("0055", "登陆账号获取异常");
        }
        boolean b = true;
        String str = null;
        String param = requestBody.getUserName();
        String url = null;
        if ("0".equals(requestBody.getParityType())) {
            if (requestBody.getPassWord() == null || "".equals(requestBody.getPassWord())) {
                throw new BusinessException("0055", "登陆密码获取异常");
            }
            String param1 = requestBody.getPassWord();
            url = "http://127.0.0.1:10002/client/list/?pageName=node-manager&formName=userSearchForm&userKeys=portal-v1.0&uctUser.w_userEname=" + param + "&uctUser.w_userPass=" + param1;
        } else if ("1".equals(requestBody.getParityType())) {
            url = "http://127.0.0.1:10002/client/list/?pageName=node-manager&formName=userSearchForm&userKeys=portal-v1.0&uctUser.w_userEname=" + param;
        } else {
            throw new BusinessException("0055", "账号失效");
        }
        try {
            str = HttpclientUtil.doGet(url, null, "UTF-8", b);
            responseBody = StringToIusLoginQueryResponseBody(str);
            response.setResponseBody(responseBody);
        } catch (Exception e) {
            throw new BusinessException("0056", "账号或密码错误！"); }

        response.setResponseBody(responseBody);
        return response;
    }

    /**
     * 支付接口
     */
    @Override
    public IusPayResponse selectPay(IusPayRequest request) throws Exception {
        IusPayResponse response = new IusPayResponse();
        IusPayResponseMain responseBody;
        IusPayRequestMain requestBody = request.getRequestBody();
        if (requestBody.getOrderNumber() == null || "".equals(requestBody.getOrderNumber())) {
            throw new BusinessException("0055", "订单号不能为空！");
        }
        String str = null;
        responseBody = StringToIusPayResponseBody(str);
        response.setResponseBody(responseBody);
        return response;
    }

    /**
     * 台账传输接口
     */
    @Override
    public IusLedgerSendResponse ledgerSend(IusLedgerSendRequest request) throws Exception {
        IusLedgerSendResponse response = new IusLedgerSendResponse();
        IusLedgerSendResponseMain responseBody;
        IusLedgerSendRequestMain requestBody = request.getRequestBody();
        if (requestBody.getAccountJson() == null || "".equals(requestBody.getAccountJson())) {
            throw new BusinessException("0055", "提交信息不能为空！");
        }
        String accountJson = requestBody.getAccountJson();
        JSONArray jsonArray = JSONArray.fromObject(accountJson);
        JSONArray ja = new JSONArray();
        for (int i = 0; i < jsonArray.size(); i++) {
            JSONObject jo = jsonArray.getJSONObject(i);
            String riskcode = jo.getString("riskcode");
            Date date = new Date();
            String year = new SimpleDateFormat("yyyy").format(date);
            String no = BillNoUtil.getNo2(riskcode, Integer.valueOf(year));
            jo.put("ORDERNO", no);
            ja.add(jo);
        }
        Map<String, String> map = new HashMap<>();
        map.put("accountJson", ja.toString());
        String str = null;
        String tokenStr = null;
        Token token = new Token();
        token.setUsername("admin");
        token.setPassword("admin");
        token.setSource("1");
        try {
            tokenStr = TokenOperate.makeToken(token);
            str = HttpclientUtil.doPostToken("http://127.0.0.1:8090/carb2b/i-api/order/sendAccountList", map, "utf-8", true, tokenStr);
            responseBody = StringToIusLedgerSendResponseBody(str);
            response.setResponseBody(responseBody);
        } catch (Exception e) {
            throw new BusinessException("0056", "台账信息存储异常！");
        }

        return response;
    }

    /**
     * 业绩查询接口
     */
    @Override
    public IusAchievementResponse selectAchievement(IusAchievementRequest request) throws Exception {
        IusAchievementResponse response = new IusAchievementResponse();
        IusAchievementResponseMain responseBody;
        String param1 = null;
        String param2 = null;
        String statrDate = null;
        String endDate = null;
        SimpleDateFormat  sdf = new SimpleDateFormat("yyyy-MM-dd");
        IusAchievementRequestMain requestBody = request.getRequestBody();
        if (requestBody.getUserEname() == null || "".equals(requestBody.getUserEname())) {
            throw new BusinessException("0055", "个人信息获取异常");
        }
        if (requestBody.getType() == null || "".equals(requestBody.getType())) {
            throw new BusinessException("0055", "查询条件获取异常");
        }
        if ("ZR".equals(requestBody.getType())) {//昨日
            statrDate = sdf.format(IusDateUtils.getBeginDayOfYesterday());
        } else if ("BZ".equals(requestBody.getType())) {//本周
            statrDate=sdf.format(IusDateUtils.getBeginDayOfWeek());
            endDate=sdf.format(IusDateUtils.getEndDayOfWeek());
        } else if ("BY".equals(requestBody.getType())) {//本月
            statrDate=sdf.format(IusDateUtils.getBeginDayOfMonth());
            endDate=sdf.format(IusDateUtils.getEndDayOfMonth());
        } else if ("ND".equals(requestBody.getType())) {//本年
            statrDate=sdf.format(IusDateUtils.getBeginDayOfYear());
            endDate=sdf.format(IusDateUtils. getEndDayOfYear());
        } else if ("QT".equals(requestBody.getType())) {//其他
            if (requestBody.getStatrDate() == null || "".equals(requestBody.getStatrDate())) {
                throw new BusinessException("0055", "日期获取异常");
            }
            if (requestBody.getEndDate() == null || "".equals(requestBody.getEndDate())) {
                throw new BusinessException("0055", "日期获取异常");
            }
            statrDate=requestBody.getStatrDate();
            endDate=requestBody.getEndDate();
        } else {
            throw new BusinessException("0055", "查询条件异常");
        }
        boolean b = true;
        String str = null;
        try {
            String url = null;
            if ("ZR".equals(requestBody.getType())) {//昨日
                url = "http://127.0.0.1:10002/client/list/?pageName=gp_cost_information&formName=gpCostInformation&userKeys=portal-v1.0&gpCostInformation.w_startDate="+statrDate;
            }else{
                url = "http://127.0.0.1:10002/client/list/?pageName=gp_cost_information&formName=gpCostInformation&userKeys=portal-v1.0&gpCostInformation.wb_startDate="+statrDate+","+endDate;
            }
            str = HttpclientUtil.doGet(url, null, "UTF-8", b);
            responseBody = StringToIusAchievementResponseBody(str);
            response.setResponseBody(responseBody);
        } catch (Exception e) {
            throw new BusinessException("0056", "数据查询异常！");
        }
        return response;
    }
    /**
     * 提现明细查询接口
     */
    @Override
    public IusBringOutTheDetailsResponse selectBringOutTheDetails(IusBringOutTheDetailsRequest request) throws Exception {
        IusBringOutTheDetailsResponse response = new IusBringOutTheDetailsResponse();
        IusBringOutTheDetailsResponseMain responseBody;
        IusBringOutTheDetailsRequestMain requestBody = request.getRequestBody();
        if (requestBody.getUserEname() == null || "".equals(requestBody.getUserEname())) {
            throw new BusinessException("0055", "用户信息获取异常");
        }
        if (requestBody.getPage() == null || requestBody.getPage() == 0 || "".equals(requestBody.getPage())) {
            throw new BusinessException("0055", "当前页数不能为空或0！");
        }

        if (requestBody.getPageSize() == null || requestBody.getPageSize() == 0
                || "".equals(requestBody.getPageSize())) {
            throw new BusinessException("0055", "分页大小不能为空或0！");
        }
        String param = requestBody.getUserEname();
        String param1 = Integer.toString(requestBody.getPage());
        String param2 = Integer.toString(requestBody.getPageSize());
        boolean b = true;
        String str = null;
        try {
            String url = "http://127.0.0.1:10002/client/list/?pageName=search-gpPresentTrack&formName=searchFrom&userKeys=portal-v1.0&gpPresentTrack.w_userEname=" + param + "&page=" + param1 + "&rows=" + param2;
            str = HttpclientUtil.doGet(url, null, "UTF-8", b);
            responseBody = StringToIusBringOutTheDetailsResponseBody(str);
            response.setResponseBody(responseBody);
        } catch (Exception e) {
            throw new BusinessException("0056", "数据查询异常！");
        }

        response.setResponseBody(responseBody);
        return response;
    }
    /**
     * 机构递归查询接口
     */
    @Override
    public IusRecursionOrgResponse selectRecursionOrg(IusRecursionOrgRequest request) throws Exception {
        IusRecursionOrgResponse response = new IusRecursionOrgResponse();
        IusRecursionOrgResponseMain responseBody;
        IusRecursionOrgRequestMain requestBody = request.getRequestBody();
        if (requestBody.getUserName() == null || "".equals(requestBody.getUserName() )) {
            throw new BusinessException("0055", "登录信息获取异常");
        }
        String param=null;
        String param1 = requestBody.getUserName();
        boolean b = true;
        String str = null;
        String str1 = null;
        try {
            String url1 = "http://127.0.0.1:10002/client/list/?pageName=user-audit&formName=searchForm&userKeys=portal-v1.0&uctUser.w_userEname=" + param1+"&result_column=uctUser.orgEname";
            str1 = HttpclientUtil.doGet(url1, null, "UTF-8", b);
            JSONObject jsonObject = JSONObject.fromObject(str1);
            JSONArray jsonArray = jsonObject.getJSONArray("rows");
            if (jsonArray.size() > 0) {
                JSONObject jo = jsonArray.getJSONObject(0);
                JSONObject channel = jo.getJSONObject("uctUser");
                param = channel.getString("orgEname");
            }else{
                throw new BusinessException("0056", "数据查询异常！");
            }
            String url = "http://127.0.0.1:10002/client/list/?pageName=IusUctOrg&formName=selectUctOrg&userKeys=portal-v1.0&orgEName=" + param;
            str = HttpclientUtil.doGet(url, null, "UTF-8", b);
            responseBody = StringToIusRecursionOrgResponseBody(str);
            response.setResponseBody(responseBody);
        } catch (Exception e) {
            throw new BusinessException("0056", "数据查询异常！");
        }
        try {
            String url = "http://127.0.0.1:10002/client/list/?pageName=IusUctOrg&formName=selectUctOrg&userKeys=portal-v1.0&orgEName=" + param;
            str = HttpclientUtil.doGet(url, null, "UTF-8", b);
            responseBody = StringToIusRecursionOrgResponseBody(str);
            response.setResponseBody(responseBody);
        } catch (Exception e) {
            throw new BusinessException("0056", "数据查询异常！");
        }

        response.setResponseBody(responseBody);
        return response;
    }
    /**
     * 销售模块回显接口
     */
    @Override
    public IusEchoQueryResponse selectEcho(IusEchoQueryRequest request) throws Exception {
        IusEchoQueryResponse response = new IusEchoQueryResponse();
        IusEchoQueryResponseMain responseBody;
        IusEchoQueryRequestMain requestBody = request.getRequestBody();
        if (requestBody.getChannelAgreeCode() == null || "".equals(requestBody.getChannelAgreeCode())) {
            throw new BusinessException("0055", "用户信息获取异常");
        }
        if (requestBody.getOrgEname() == null || "".equals(requestBody.getOrgEname())) {
            throw new BusinessException("0055", "用户信息获取异常");
        }
        String orgEname = requestBody.getOrgEname();
        String channelAgreeCode = requestBody.getChannelAgreeCode();
        boolean b = true;
        String str = null;
        try {
            String url = "http://127.0.0.1:10002/client/list/?pageName=select-IusEchoQuery&formName=select&userKeys=portal-v1.0&orgEname=" + orgEname + "&channelAgreeCode=" + channelAgreeCode;
            str = HttpclientUtil.doGet(url, null, "UTF-8", b);
            responseBody = StringToIusEchoQueryResponseBody(str);
            response.setResponseBody(responseBody);
        } catch (Exception e) {
            throw new BusinessException("0056", "数据查询异常！");
        }
        return response;
    }
    /**
     * 保险公司查询接口
     */
    @Override
    public InsurerQueryResponse selectInsurer(InsurerQueryRequest request) throws Exception {
        InsurerQueryResponse response = new InsurerQueryResponse();
        InsurerQueryResponseMain responseBody;
        InsurerQueryRequestMain requestBody = request.getRequestBody();
        if (requestBody.getChannelAgreeCode() == null || "".equals(requestBody.getChannelAgreeCode())) {
            throw new BusinessException("0055", "渠道协议获取异常");
        }
        String param = requestBody.getChannelAgreeCode();
        boolean b = true;
        String str = null;
        try {
            String url = "http://127.0.0.1:10002/client/list/?pageName=ggInsurer-ggChannelAgreeDetail&formName=select&userKeys=portal-v1.0&ggChannelAgreeDetail.w_channelAgreeCode=" + param ;
            str = HttpclientUtil.doGet(url, null, "UTF-8", b);
            responseBody = StringToInsurerQueryResponseBody(str);
            response.setResponseBody(responseBody);
        } catch (Exception e) {
            throw new BusinessException("0056", "数据查询异常！");
        }

        response.setResponseBody(responseBody);
        return response;
    }

    /**
     * 销售模块回显返回数据转为对象
     *
     * @param
     * @return
     * @param. policyInfo
     */
    public IusEchoQueryResponseMain StringToIusEchoQueryResponseBody(String str) throws Exception {
        PolicyInfo policyInfo = new PolicyInfo();
        IusEchoQueryResponseMain response = new IusEchoQueryResponseMain();
        JSONObject jsonMap = new JSONObject();
        Map map =(Map) ToolUtils.json2Obj(str,Map.class);
        List list = (List)map.get("rows");
        try {
            if(list.size()>0){
                jsonMap.put("body", list);
            }else {
                throw new BusinessException("0055", "数据库查询异常");
            }
            if ("T".equals((String)map.get("flag"))) {
                policyInfo.setMsg("成功");
                policyInfo.setStatus("1");
                System.out.println(map.get("total"));
                policyInfo.setCount(list.size());
            } else {
                throw new BusinessException("0055", "数据库查询异常");
            }
        } catch (Exception e) {
            throw new BusinessException("0056", "数据转换异常！");
        } finally {
            if (!("T".equals((String) map.get("flag")))) {
                policyInfo.setMsg("失败");
                policyInfo.setStatus("0");
                policyInfo.setCount(list.size());
            }
            if ("0".equals(String.valueOf(map.get("total")))) {
                policyInfo.setMsg("数据库无数据");
                policyInfo.setStatus("2");
                policyInfo.setCount(list.size());
            }
        }
        policyInfo.setBody(jsonMap.toString());
        response.setBody(policyInfo.getBody());
        response.setStatus(policyInfo.getStatus());
        response.setMsg(policyInfo.getMsg());
        response.setCount(policyInfo.getCount());
        return response;
    }
    /**
     * 机构返回数据转为对象
     *
     * @param
     * @return
     * @param. policyInfo
     */
    public IusOrgQueryResponseMain StringToIusResponseBody(String str) throws Exception {
        PolicyInfo policyInfo = new PolicyInfo();
        IusOrgQueryResponseMain response = new IusOrgQueryResponseMain();
        net.sf.json.JSONObject jsonMap = new net.sf.json.JSONObject();
        net.sf.json.JSONArray ja = new net.sf.json.JSONArray();
        net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(str);
        try {
            net.sf.json.JSONArray jsonArray = jsonObject.getJSONArray("rows");
            if (jsonArray.size() > 0) {
                for (int i = 0; i < jsonArray.size(); i++) {
                    net.sf.json.JSONObject jo = jsonArray.getJSONObject(i);
                    net.sf.json.JSONObject channel = jo.getJSONObject("uctOrg");
                    ja.add(channel);
                    jsonMap.put("body", ja);
                }
            }
            if ("T".equals(jsonObject.getString("flag"))) {
                policyInfo.setMsg("成功");
                policyInfo.setStatus("1");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            } else {
                throw new BusinessException("0055", "数据查询异常");
            }
        } catch (Exception e) {
            throw new BusinessException("0056", "数据转换异常！");
        } finally {
            if (!("T".equals(jsonObject.getString("flag")))) {
                policyInfo.setMsg("失败");
                policyInfo.setStatus("0");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            }
            if ("0".equals(jsonObject.getString("total"))) {
                policyInfo.setMsg("数据库无数据");
                policyInfo.setStatus("2");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            }
        }
        policyInfo.setBody(jsonMap.toString());
        response.setBody(policyInfo.getBody());
        response.setStatus(policyInfo.getStatus());
        response.setMsg(policyInfo.getMsg());
        response.setCount(policyInfo.getCount());
        return response;
    }


    /**
     * 短信返回数据转为对象
     *
     * @param
     * @return
     * @param. policyInfo
     */
    public IusMessagingResponseMain StringToIusMessagingResponseBody(String str) throws Exception {
        IusMessagingResponseMain response = new IusMessagingResponseMain();
        str = "{\"body\":[{\"messaging\":\"123456\"}]}";
        response.setBody(str);
        response.setCount(1);
        response.setMsg("成功");
        response.setStatus("1");
        return response;
    }


    /**
     * 渠道协议返回数据转为对象
     *
     * @param
     * @return
     * @param. policyInfo
     */
    public IusChannelQueryResponseMain StringToresponseBody(String str) throws Exception {
        PolicyInfo policyInfo = new PolicyInfo();
        IusChannelQueryResponseMain response = new IusChannelQueryResponseMain();
        net.sf.json.JSONObject jsonMap = new net.sf.json.JSONObject();
        net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(str);
        try {
            net.sf.json.JSONArray jsonArray = jsonObject.getJSONArray("rows");
            if (jsonArray.size() > 0) {
                jsonMap.put("body", jsonArray);
            }
            if ("T".equals(jsonObject.getString("flag"))) {
                policyInfo.setMsg("成功");
                policyInfo.setStatus("1");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            } else {
                throw new BusinessException("0055", "数据查询异常");
            }
        } catch (Exception e) {
            throw new BusinessException("0056", "数据转换异常！");
        } finally {
            if (!("T".equals(jsonObject.getString("flag")))) {
                policyInfo.setMsg("失败");
                policyInfo.setStatus("0");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            }
            if ("0".equals(jsonObject.getString("total"))) {
                policyInfo.setMsg("数据库无数据");
                policyInfo.setStatus("2");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            }
        }
        policyInfo.setBody(jsonMap.toString());
        response.setBody(policyInfo.getBody());
        response.setStatus(policyInfo.getStatus());
        response.setMsg(policyInfo.getMsg());
        response.setCount(policyInfo.getCount());
        return response;
    }

    /**
     * 保险协议返回数据转为对象
     *
     * @param
     * @return
     * @param. policyInfo
     */
    public List<SaleBXInformationVo> String1ToInt(String str) throws Exception {
        Map<String, String> map = new HashMap<String, String>();
        PolicyInfo policyInfo = new PolicyInfo();
        List<SaleBXInformationVo> list = new ArrayList<SaleBXInformationVo>();
        IusInsuredAgreeQueryResponseMain response = new IusInsuredAgreeQueryResponseMain();
        net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(str);
        try {
            net.sf.json.JSONArray jsonArray = jsonObject.getJSONArray("rows");
            if (jsonArray.size() > 0) {
                for (int i = 0; i < jsonArray.size(); i++) {
                    SaleBXInformationVo sv = new SaleBXInformationVo();
                    net.sf.json.JSONObject jo = jsonArray.getJSONObject(i);
                    net.sf.json.JSONObject joo = jo.getJSONObject("ggInsuredAgree");
                    sv.setChannelAgreeCode(joo.getString("agreeCode"));
                    sv.setChannelAgreeName(joo.getString("agreeName"));
                    list.add(sv);
                }
            } else {
                throw new BusinessException("0055", "数据库无数据");
            }

        } catch (Exception e) {
            throw new BusinessException("0056", "数据转换异常！");
        }
        return list;
    }

    /**
     * 物流返回数据转为对象
     *
     * @param
     * @return
     * @param. policyInfo
     */
    public IusLogisticsQueryResponseMain StringToIusLogisticsResponseBody(String str) throws Exception {
        PolicyInfo policyInfo = new PolicyInfo();
        IusLogisticsQueryResponseMain response = new IusLogisticsQueryResponseMain();
        net.sf.json.JSONObject jsonMap = new net.sf.json.JSONObject();
        net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(str);
        try {
            net.sf.json.JSONArray jsonArray = jsonObject.getJSONArray("Traces");
            jsonMap.put("body", jsonArray);
            if ("true".equals(jsonObject.getString("Success"))) {
                policyInfo.setMsg("成功");
                policyInfo.setStatus("1");
                policyInfo.setCount(1);
            } else {
                throw new BusinessException("0055", "数据查询异常");
            }
        } catch (Exception e) {
            throw new BusinessException("0056", "数据转换异常！");
        } finally {
            if (!("true".equals(jsonObject.getString("Success")))) {
                policyInfo.setMsg("失败");
                policyInfo.setStatus("0");
                policyInfo.setCount(1);
            }
        }
        policyInfo.setBody(jsonMap.toString());
        response.setBody(policyInfo.getBody());
        response.setStatus(policyInfo.getStatus());
        response.setMsg(policyInfo.getMsg());
        response.setCount(policyInfo.getCount());
        return response;
    }


    /**
     * 银联加修改佣金返回数据转为对象
     *
     * @param
     * @return
     * @param. policyInfo
     */
    public IusMoneyResponseMain StringToIusMoneyResponseBody(String str) throws Exception {
        IusMoneyResponseMain response = new IusMoneyResponseMain();
        PolicyInfo policyInfo = new PolicyInfo();
        net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(str);
        try {
            String jsonArray = jsonObject.getString("flag");
            if ("T".equals(jsonArray)) {
                policyInfo.setMsg("成功");
                policyInfo.setStatus("1");
                policyInfo.setCount(1);
                str = "{\"body\":[{\"messaging\":\"提现成功\"}]}";
            } else {
                throw new BusinessException("0055", "数据查询异常");
            }
        } catch (Exception e) {
            throw new BusinessException("0056", "数据转换异常！");
        } finally {
            if (!("T".equals(jsonObject.getString("flag")))) {
                policyInfo.setMsg("失败");
                policyInfo.setStatus("0");
                policyInfo.setCount(0);
            }
        }
        response.setBody(str);
        response.setStatus(policyInfo.getStatus());
        response.setMsg(policyInfo.getMsg());
        response.setCount(policyInfo.getCount());
        return response;
    }

    /**
     * 佣金返回数据转为对象
     *
     * @param
     * @return
     * @param. policyInfo
     */
    public IusSettletFeeResponseMain StringToGpSettletFeeResponseBody(String str) throws Exception {
        PolicyInfo policyInfo = new PolicyInfo();
        IusSettletFeeResponseMain response = new IusSettletFeeResponseMain();
        net.sf.json.JSONObject jsonMap = new net.sf.json.JSONObject();
        net.sf.json.JSONArray ja = new net.sf.json.JSONArray();
        net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(str);
        try {
            net.sf.json.JSONArray jsonArray = jsonObject.getJSONArray("rows");
            if (jsonArray.size() > 0) {
                for (int i = 0; i < jsonArray.size(); i++) {
                    net.sf.json.JSONObject jo = jsonArray.getJSONObject(i);
                    net.sf.json.JSONObject channel = jo.getJSONObject("gpBalance");
                    ja.add(channel);
                    jsonMap.put("body", ja);
                }
            }
            if ("T".equals(jsonObject.getString("flag"))) {
                policyInfo.setMsg("成功");
                policyInfo.setStatus("1");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            } else {
                throw new BusinessException("0055", "数据查询异常");
            }
        } catch (Exception e) {
            throw new BusinessException("0056", "数据转换异常！");
        } finally {
            if (!("T".equals(jsonObject.getString("flag")))) {
                policyInfo.setMsg("失败");
                policyInfo.setStatus("0");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            }
            if ("0".equals(jsonObject.getString("total"))) {
                policyInfo.setMsg("数据库无数据");
                policyInfo.setStatus("2");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            }
        }
        policyInfo.setBody(jsonMap.toString());
        response.setBody(policyInfo.getBody());
        response.setStatus(policyInfo.getStatus());
        response.setMsg(policyInfo.getMsg());
        response.setCount(policyInfo.getCount());
        return response;
    }
    /**
     * 机构返回数据转为对象
     *
     * @param
     * @return
     * @param. policyInfo
     */
    public IusAccountResponseMain StringToIusAccountResponseBody(String str) throws Exception {
        PolicyInfo policyInfo = new PolicyInfo();
        IusAccountResponseMain response = new IusAccountResponseMain();
        net.sf.json.JSONObject jsonMap = new net.sf.json.JSONObject();
        net.sf.json.JSONArray ja = new net.sf.json.JSONArray();
        net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(str);
        try {
            net.sf.json.JSONArray jsonArray = jsonObject.getJSONArray("rows");
            if (jsonArray.size() > 0) {
                for (int i = 0; i < jsonArray.size(); i++) {
                    net.sf.json.JSONObject jo = jsonArray.getJSONObject(i);
                    net.sf.json.JSONObject channel = jo.getJSONObject("guAccount");
                    ja.add(channel);
                    jsonMap.put("body", ja);
                }
            }
            if ("T".equals(jsonObject.getString("flag"))) {
                policyInfo.setMsg("成功");
                policyInfo.setStatus("1");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            } else {
                throw new BusinessException("0055", "数据查询异常");
            }
        } catch (Exception e) {
            throw new BusinessException("0056", "数据转换异常！");
        } finally {
            if (!("T".equals(jsonObject.getString("flag")))) {
                policyInfo.setMsg("失败");
                policyInfo.setStatus("0");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            }
            if ("0".equals(jsonObject.getString("total"))) {
                policyInfo.setMsg("数据库无数据");
                policyInfo.setStatus("2");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            }
        }
        policyInfo.setBody(jsonMap.toString());
        response.setBody(policyInfo.getBody());
        response.setStatus(policyInfo.getStatus());
        response.setMsg(policyInfo.getMsg());
        response.setCount(policyInfo.getCount());
        return response;
    }

    /**
     * 登陆数据转为对象
     *
     * @param
     * @return
     * @param. policyInfo
     */
    public IusLoginQueryResponseMain StringToIusLoginQueryResponseBody(String str) throws Exception {
        PolicyInfo policyInfo = new PolicyInfo();
        IusLoginQueryResponseMain response = new IusLoginQueryResponseMain();
        net.sf.json.JSONObject jsonMap = new net.sf.json.JSONObject();
        net.sf.json.JSONArray ja = new net.sf.json.JSONArray();
        net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(str);
        try {
            net.sf.json.JSONArray jsonArray = jsonObject.getJSONArray("rows");
            if (jsonArray.size() > 0) {
                jsonMap.put("body", jsonArray);
            } else {
                throw new BusinessException("0055", "该账号不存在");
            }
            if ("T".equals(jsonObject.getString("flag"))) {
                policyInfo.setMsg("成功");
                policyInfo.setStatus("1");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            } else {
                throw new BusinessException("0055", "密码错误");
            }
        } catch (Exception e) {
            throw new BusinessException("0056", "数据转换异常！");
        } finally {
            if (!("T".equals(jsonObject.getString("flag")))) {
                policyInfo.setMsg("失败");
                policyInfo.setStatus("0");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            }
            if ("0".equals(jsonObject.getString("total"))) {
                policyInfo.setMsg("该账号不存在");
                policyInfo.setStatus("2");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            }
        }
        policyInfo.setBody(jsonMap.toString());
        response.setBody(policyInfo.getBody());
        response.setStatus(policyInfo.getStatus());
        response.setMsg(policyInfo.getMsg());
        response.setCount(policyInfo.getCount());
        return response;
    }

    /**
     * 支付返回数据转为对象
     *
     * @param
     * @return
     * @param. policyInfo
     */
    public IusPayResponseMain StringToIusPayResponseBody(String str) throws Exception {
        IusPayResponseMain response = new IusPayResponseMain();
        str = "{\"body\":[{\"messaging\":\"支付成功\"}]}";
        response.setBody(str);
        response.setCount(1);
        response.setMsg("成功");
        response.setStatus("1");
        return response;
    }

    /**
     * 台账传输返回数据转为对象
     *
     * @param
     * @return
     * @param. policyInfo
     */
    public IusLedgerSendResponseMain StringToIusLedgerSendResponseBody(String str) throws Exception {
        IusLedgerSendResponseMain response = new IusLedgerSendResponseMain();
        if (str.equals("1")) {
            str = "{\"body\":[{\"messaging\":\"保存成功\"}]}";
        } else {

        }
        response.setBody(str);
        response.setCount(1);
        response.setMsg("成功");
        response.setStatus("1");
        return response;
    }
    /**
     * 提现明细返回数据转为对象
     *
     * @param
     * @return
     * @param. policyInfo
     */
    public IusBringOutTheDetailsResponseMain StringToIusBringOutTheDetailsResponseBody(String str) throws Exception {
        PolicyInfo policyInfo = new PolicyInfo();
        IusBringOutTheDetailsResponseMain response = new IusBringOutTheDetailsResponseMain();
        net.sf.json.JSONObject jsonMap = new net.sf.json.JSONObject();
        net.sf.json.JSONArray ja = new net.sf.json.JSONArray();
        net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(str);
        try {
            net.sf.json.JSONArray jsonArray = jsonObject.getJSONArray("rows");
            if (jsonArray.size() > 0) {
                for (int i = 0; i < jsonArray.size(); i++) {
                    net.sf.json.JSONObject jo = jsonArray.getJSONObject(i);
                    net.sf.json.JSONObject channel = jo.getJSONObject("gpPresentTrack");
                    ja.add(channel);
                    jsonMap.put("body", ja);
                }
            }
            if ("T".equals(jsonObject.getString("flag"))) {
                policyInfo.setMsg("成功");
                policyInfo.setStatus("1");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            } else {
                throw new BusinessException("0055", "数据查询异常");
            }
        } catch (Exception e) {
            throw new BusinessException("0056", "数据转换异常！");
        } finally {
            if (!("T".equals(jsonObject.getString("flag")))) {
                policyInfo.setMsg("失败");
                policyInfo.setStatus("0");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            }
            if ("0".equals(jsonObject.getString("total"))) {
                policyInfo.setMsg("数据库无数据");
                policyInfo.setStatus("2");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            }
        }
        policyInfo.setBody(jsonMap.toString());
        response.setBody(policyInfo.getBody());
        response.setStatus(policyInfo.getStatus());
        response.setMsg(policyInfo.getMsg());
        response.setCount(policyInfo.getCount());
        return response;
    }
    /**
     * 递归查询机构返回数据转为对象
     *
     * @param
     * @return
     * @param. policyInfo
     */
    public IusRecursionOrgResponseMain StringToIusRecursionOrgResponseBody(String str) throws Exception {
        PolicyInfo policyInfo = new PolicyInfo();
        IusRecursionOrgResponseMain response = new IusRecursionOrgResponseMain();
        net.sf.json.JSONObject jsonMap = new net.sf.json.JSONObject();
        net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(str);
        try {
            net.sf.json.JSONArray jsonArray = jsonObject.getJSONArray("rows");
            jsonMap.put("body", jsonArray);
            if ("T".equals(jsonObject.getString("flag"))) {
                policyInfo.setMsg("成功");
                policyInfo.setStatus("1");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            } else {
                throw new BusinessException("0055", "数据查询异常");
            }
        } catch (Exception e) {
            throw new BusinessException("0056", "数据转换异常！");
        } finally {
            if (!("T".equals(jsonObject.getString("flag")))) {
                policyInfo.setMsg("失败");
                policyInfo.setStatus("0");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            }
            if ("0".equals(jsonObject.getString("total"))) {
                policyInfo.setMsg("数据库无数据");
                policyInfo.setStatus("1");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            }
        }
        policyInfo.setBody(jsonMap.toString());
        response.setBody(policyInfo.getBody());
        response.setStatus(policyInfo.getStatus());
        response.setMsg(policyInfo.getMsg());
        response.setCount(policyInfo.getCount());
        return response;
    }
    /**
     * 业绩查询返回数据转为对象
     *
     * @param
     * @return
     * @param. policyInfo
     */
    public IusAchievementResponseMain StringToIusAchievementResponseBody(String str) throws Exception {
        PolicyInfo policyInfo = new PolicyInfo();
        IusAchievementResponseMain response = new IusAchievementResponseMain();
        net.sf.json.JSONObject jsonMap = new net.sf.json.JSONObject();
        net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(str);
        try {
            net.sf.json.JSONArray jsonArray = jsonObject.getJSONArray("rows");
            jsonMap.put("body", jsonArray);
            if ("T".equals(jsonObject.getString("flag"))) {
                policyInfo.setMsg("成功");
                policyInfo.setStatus("00");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            } else {
                throw new BusinessException("0055", "数据查询异常");
            }
        } catch (Exception e) {
            throw new BusinessException("0056", "数据转换异常！");
        } finally {
            if (!("T".equals(jsonObject.getString("flag")))) {
                policyInfo.setMsg("失败");
                policyInfo.setStatus("0");
            }
            if ("0".equals(jsonObject.getString("total"))) {
                policyInfo.setMsg("数据库无数据");
                policyInfo.setStatus("1");
            }
        }
        policyInfo.setBody(jsonMap.toString());
        response.setData(policyInfo.getBody());
        response.setFlag(policyInfo.getStatus());
        response.setResultMsg(policyInfo.getMsg());
        return response;
    }
    /**
     * 提现明细返回数据转为对象
     *
     * @param
     * @return
     * @param. policyInfo
     */
    public InsurerQueryResponseMain StringToInsurerQueryResponseBody(String str) throws Exception {
        PolicyInfo policyInfo = new PolicyInfo();
        InsurerQueryResponseMain response = new InsurerQueryResponseMain();
        net.sf.json.JSONObject jsonMap = new net.sf.json.JSONObject();
        net.sf.json.JSONArray ja = new net.sf.json.JSONArray();
        net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(str);
        try {
            net.sf.json.JSONArray jsonArray = jsonObject.getJSONArray("rows");
            if (jsonArray.size() > 0) {
                for (int i = 0; i < jsonArray.size(); i++) {
                    net.sf.json.JSONObject jo = jsonArray.getJSONObject(i);
                    net.sf.json.JSONObject channel = jo.getJSONObject("ggInsurer");
                    ja.add(channel);
                    jsonMap.put("body", ja);
                }
            }
            if ("T".equals(jsonObject.getString("flag"))) {
                policyInfo.setMsg("成功");
                policyInfo.setStatus("1");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            } else {
                throw new BusinessException("0055", "数据查询异常");
            }
        } catch (Exception e) {
            throw new BusinessException("0056", "数据转换异常！");
        } finally {
            if (!("T".equals(jsonObject.getString("flag")))) {
                policyInfo.setMsg("失败");
                policyInfo.setStatus("0");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            }
            if ("0".equals(jsonObject.getString("total"))) {
                policyInfo.setMsg("数据库无数据");
                policyInfo.setStatus("2");
                policyInfo.setCount(Integer.valueOf(jsonObject.getString("total")));
            }
        }
        policyInfo.setBody(jsonMap.toString());
        response.setBody(policyInfo.getBody());
        response.setStatus(policyInfo.getStatus());
        response.setMsg(policyInfo.getMsg());
        response.setCount(policyInfo.getCount());
        return response;
    }
}
